/*******************************************************************************
 * Copyright (c) 2014 Davide Riccardo Caliendo .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 ******************************************************************************/

package language.value.expression;

import language.util.LambdaIdLookup;
import language.value.IValue;
import language.value.type.Type;
import exception.CoercionException;
import exception.WrongIdException;

public class GroupedExpression extends Expression {
    private static final long serialVersionUID = 2L;
    protected Expression v;
    
    public GroupedExpression(Expression e) {
        v = e;
    }
    
    @Override
    public IValue getValue(LambdaIdLookup<String, IValue> idl) throws CoercionException, WrongIdException {
        cached_ival = v.getValue(idl);
        return cached_ival;
    }

    @Override
    public Type getType() {
        return cached_ival.getType();
    }

    @Override
    public ExprType getExprType() {
        return v.getExprType();
    }

    @Override
    public void rename(String old_id, String new_id) {
        v.rename(old_id, new_id);
    }

    @Override
    public IValue clone() {
        return v.clone();
    }

    @Override
    public String toString() {
        return "(" + v.toString() + ")";
    }
}
